/**
 * Created by lenovo on 2017/5/9.
 */
import React from 'react';

import starUrl from '../img/imgBrandPage/score@2x.png';
import star1Url from '../img/imgBrandPage/star_gray.png';

class StoreStars extends React.Component{
    constructor(props){
        super(props);
    }

    render(){
        let numOfStars = parseInt(this.props.numOfStars);
        let stars = [
            <img className="starSet" key={new Date()+0} src={star1Url} />,
            <img className="starSet" key={new Date()+1} src={star1Url} />,
            <img className="starSet" key={new Date()+2} src={star1Url} />,
            <img className="starSet" key={new Date()+3} src={star1Url} />,
            <img className="starSet" key={new Date()+4} src={star1Url} />
        ];

        //数据流使用
        if(numOfStars<0 || numOfStars>5){
            return(
                <div className="">
                    {stars}
                </div>
            );
        }else{
            const starList = stars.map(
                (item,index)=>{
                    if(numOfStars>0){
                        numOfStars--;
                        return(
                            <img className="starSet" key={new Date()+index} src={starUrl} />
                        );
                    }else{
                        return(
                            <img className="starSet" key={new Date()+index} src={star1Url} />
                        );
                    }
                }
            );

            return(
                <div className="">
                    {starList}
                </div>
            );
        }

        //界面演示使用

    }
};

export default StoreStars;